from langchain.schema import SystemMessage, HumanMessage
from langchain.prompts import ChatPromptTemplate
from langchain.schema.runnable import RunnableMap
from langserve import RemoteRunnable

joke_chain = RemoteRunnable("http://localhost:8000/joke/")
openai = RemoteRunnable("http://localhost:8000/openai/")
result = joke_chain.invoke({"topic": "程序员"})
print(result)


prompt = ChatPromptTemplate.from_messages(
    [("system", "Tell me a long story about {topic}")]
)

chain = prompt | RunnableMap({
    "openai": openai
})

chain.batch([{"topic": "parrots"}, {"topic": "cats"}])
